import { ZYSDK } from "../../../ZYSDK";
import { SdkEventModel } from "../model/SdkEventModel";
import { UIMgr } from "../manager/viewMgr";
import LayaUtils from "../util/LayaUtils";
import AbstractBean from "./AbstractBean";
import { WXAPIMgr } from "../wxComponent/concrete/WXAPIManager";

/** 
 * 
 * @author: xj.huang
 * @date: 2021/07/31 12:05:41
 */
export default class LoadResBean extends AbstractBean {
    private _curProgress = 0;
    constructor() {
        super("LoadResBean");
    }
    public async start() {
        SdkEventModel.initEventMode()
        let loadView = UIMgr.onGetRuntime(ViewRes.VIEW_LOAD) as ZYSDK.loading;
        let allPro1=0;
        await WXAPIMgr.asyncLoad(ZYSDK.config.load.subpackages,this,(pro)=>{
            allPro1 = (pro * 460)/2
            loadView.pro.width = allPro1
        })
        await LayaUtils.asyncCreateRes(ZYSDK.config.load.reses2Load, async (pro) => {
            loadView.pro.width = allPro1+(pro * 460)/2
        })
        console.log("更新完成")
        loadView.close()
        this.finish();
    }
} 